/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.fi.PA165.musiclibrarybackend.transfers;

import cz.muni.fi.PA165.musiclibraryapi.dto.UserDTOInterface;
import cz.muni.fi.PA165.musiclibrarybackend.dto.UserDTO;
import cz.muni.fi.PA165.musiclibrarybackend.entities.User;


public class UserT {
    
        public static UserDTOInterface UserToDTO(User user){
        if (user == null) {
            throw new IllegalArgumentException();
        }
        
        UserDTO userDTO = new UserDTO();
        
        userDTO.setName(user.getName());
        userDTO.setPassword(user.getPassword());
        userDTO.setAdmin(user.getAdmin());
                
        return userDTO;        
    }
    
    public static User DTOtoUser(UserDTOInterface userDTO){
        if (userDTO == null) {
            throw new IllegalArgumentException();
        }
        
        User user = new User();
        
        
        user.setName(userDTO.getName());
        user.setPassword(userDTO.getPassword());
        user.setAdmin(userDTO.getAdmin());
                
        return user;     
    }   
    
}
